//
//  TableViewController.h
//  Linkage
//
//  Created by LeeJay on 16/8/22.
//  Copyright © 2016年 LeeJay. All rights reserved.
//

#import <UIKit/UIKit.h>

@class ClassificationViewController;

@protocol CategoryModel <NSObject>

@property(nonatomic,copy,readonly)NSString *categoryTitle;
@property(nonatomic,strong,readonly)NSArray *dataArr;

@property(nonatomic,assign)int  selectCount;

@end

@protocol ClassificationDelegate <NSObject>

-(UITableViewCell *)classificationVC:(ClassificationViewController *)classificationVC contentTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath andModel:(id)model;
-(UIView *)classificationVC:(ClassificationViewController *)classificationVC contentTableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section andModel:(id<CategoryModel>)model; //不能传nil
-(CGFloat)classificationVC:(ClassificationViewController *)classificationVC contentTableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section andModel:(id<CategoryModel>)model; //不需要header 返回0.01

@optional
-(CGFloat)classificationVC:(ClassificationViewController *)classificationVC contentTableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath andModel:(id)model;
@end

typedef void(^ContentTableViewRegisteredCell)(UITableView *tableView);

@interface ClassificationViewController : UIViewController
@property(nonatomic,strong)UIColor *categoryDefaultBackgroundColor;
@property(nonatomic,strong)UIColor *categorySelectBackgroundColor;

@property(nonatomic,assign,readwrite)CGFloat categoryTableCellWidth;
@property(nonatomic,assign)CGFloat categoryTableCellHieght;


-(void)addDataArr:(NSArray <CategoryModel>*)arr;

-(instancetype)init NS_UNAVAILABLE;
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil NS_UNAVAILABLE;

-(instancetype)initWithDelegate:(id<ClassificationDelegate>)delegate registeredCell:(ContentTableViewRegisteredCell)registeredCell;


-(void)selcetObject:(id)object;
-(void)cancelSelcetObject:(id)object;
@end

/*    
 
 #import "ClassificationViewController.h"
 #import "ClassificationCell.h"
 #import "Classification.h"
 
 ClassificationViewController *vc = [[ClassificationViewController alloc]initWithDelegate:self registeredCell:^(UITableView *tableView) {
 
 [tableView registerNib:[UINib nibWithNibName:@"ClassificationCell" bundle:nil] forCellReuseIdentifier:@"ClassificationCell"];
 }];
 self.classificationVC = vc;
 
 vc.categoryTableCellWidth = 90;
 vc.categoryTableCellHieght = 50;
 
 NSMutableArray *arr = [NSMutableArray array];
 for (int i = 0; i< 10; i++) {
 Classification *obj = [[Classification alloc]init];
 obj.categoryTitle = [NSString stringWithFormat:@"%d",i];
 [arr addObject:obj];
 }
 [vc addDataArr:arr];
 
 vc.categoryDefaultBackgroundColor = kF2F2F2;
 vc.categorySelectBackgroundColor = [UIColor whiteColor];
 [self pushViewController:vc animated:YES];
 }
 -(UITableViewCell *)contentTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath andModel:(id)model
 {
 ClassificationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ClassificationCell" forIndexPath:indexPath];
 
 ClassificationSubClass *subClass = model;
 WeakSelf(self)
 cell.selectBtn.selected = subClass.selected;
 cell.selectAction = ^(UIButton *obj) {
 subClass.selected = obj.selected;
 if (obj.selected) {
 [weakself.classificationVC selcetObject:model];
 }else {
 [weakself.classificationVC cancelSelcetObject:model];
 }
 };
 
 return cell;
 }
 -(UIView *)contentTableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section andModel:(id<CategoryModel>)model
 {
 UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 90, 30)];
 label.backgroundColor = [UIColor whiteColor];
 label.font = [UIFont systemFontOfSize:14];
 label.text = model.categoryTitle;
 return label;
 }
 -(CGFloat )contentTableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section andModel:(id<CategoryModel>)model
 {
 return 30;
 }
 */
